﻿using System;
using Medianamik.Core;
using Medianamik.Core.DAL.Repositories;
using Medianamik.Core.Sugar;
using Medianamik.UI.Web.MVP.Presentation;
using Medianamik.UI.Web.Shop.Data;
using Medianamik.UI.Web.Shop.Data.Repositories;
using IModelGroup = Medianamik.UI.Web.Shop.Data.Interfaces.IModelGroup;

namespace Medianamik.UI.Web.Shop.Presentation.Presenters
{
    public class ModelGroupListPresenter<T, TView> : ModulePresenterWithGrid<T, TView,
        IModelGroupRepository<T>, INodeTypeRepository, IMedianamikRepository<IMedianamikDTOWithName>>
        where T : class, IModelGroup
        where TView : class, IModelGroups 

    {
        public ModelGroupListPresenter(TView view,
            IModelGroupRepository<T> modelGroupRepository, INodeTypeRepository nodeTypeRepository, 
            IMedianamikRepository<IMedianamikDTOWithName> baseTypeRepository)
            : base(view, modelGroupRepository, nodeTypeRepository, baseTypeRepository)
        {
        }

        protected override string TypeSelectorUrl
        {
            get
            {
                return View.EditPageUrl
                    .AddParam(DefaultParamNames.ReturnURL, BuildReturnUrl().UrlEncodeBase64())
                    .AddParam(DefaultParamNames.ParentNodeID, ParentNodeId)
                    .AddParam(DefaultParamNames.TypeID, View.BaseTypeId);
            }
        }

        protected override bool HasMultipleTypes
        {
            get
            {
                return false;
            }
        }
    }

    public class ModelGroupListPresenter : ModelGroupListPresenter<ModelGroup, IModelGroups>
    {
        public ModelGroupListPresenter(IModelGroups view, IModelGroupRepository<ModelGroup> modelGroupRepository, INodeTypeRepository nodeTypeRepository, IMedianamikRepository<IMedianamikDTOWithName> baseTypeRepository) : base(view, modelGroupRepository, nodeTypeRepository, baseTypeRepository)
        {
        }
    }
}